<template>
	<div>
		<el-row>
			<el-col :span="10">
				<el-input placeholder="请输入患者姓名" v-model="medName.realname">
					<el-button icon="el-icon-search"></el-button>
				</el-input>
			</el-col>
			<el-col :span="1">
				<el-button type="primary" @click="SearchByName()">查询</el-button>
			</el-col>
			<el-col :span="5">
				<el-button type="success" @click="selectDefinite()">已确诊</el-button>
				<el-button type="danger" @click="selectUndefinite()">未确诊</el-button>
			</el-col>
		</el-row>
		<br /><br />
		<el-table :data="tableData" border style="width: 100%" height="750">
			<el-table-column prop="id" label="ID" width="150" height="100">
			</el-table-column>
			<el-table-column prop="casenumber" label="病例号" width="150">
			</el-table-column>
			<el-table-column prop="registid" label="挂号ID" width="150">
			</el-table-column>
			<el-table-column prop="readme" label="主诉" width="200">
			</el-table-column>
			<el-table-column prop="present" label="现病史" width="500">
			</el-table-column>
			<el-table-column prop="presenttreat" label="现病治疗情况" width="500">
			</el-table-column>
			<el-table-column prop="history" label="既往史" width="500">
			</el-table-column>
			<el-table-column prop="allergy" label="过敏史" width="350">
			</el-table-column>
			<el-table-column prop="physique" label="体格检查" width="250">
			</el-table-column>
			<el-table-column prop="proposal" label="检查建议" width="250">
			</el-table-column>
			<el-table-column prop="careful" label="注意事项" width="250">
			</el-table-column>
			<el-table-column prop="checkresult" label="检查结果" width="150">
			</el-table-column>
			<el-table-column prop="diagnosis" label="诊断意见" width="250">
			</el-table-column>
			<el-table-column prop="handling" label="处理意见" width="250">
			</el-table-column>
			<el-table-column prop="casestate" label="病例状态" width="100">
				<template slot-scope="scope">
					<el-tag size="medium" type="danger" v-if="scope.row.casestate===2">已提交</el-tag>
					<el-tag size="medium" type="primary" v-else-if="scope.row.casestate===1">暂存</el-tag>
					<el-tag size="medium" type="warning" v-else>确诊</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="操作" width="150">
				<template slot-scope="scope">
					<el-button type="primary" icon="el-icon-edit" size="mini" @click="Edit(scope.row)"></el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	export default {
		name: "HomePage",
		data() {
			return {
				tableData: [],
				medName: {
					realname: ''
				},
			}
		},
		created() {
			let url = '/MedicalRecord/selectAll'
			this.$axios.post(url)
				.then((resp) => {
					this.tableData = resp.data;
					console.log(this.tableData)
				})
		},
		methods: {
			SearchByName() {
				let url = '/MedicalRecord/selectByRealName'
				let param = this.$qs.stringify(this.medName)
				this.$axios.post(url, param)
					.then((resp) => {
						this.$router.push({
							path: '/PatientPage',
							query: {
								casenumber: resp.data.casenumber
							},
						})
						// console.log('--this.med.id', resp.casenumber);
						this.tableData = resp.data;
						console.log('this.tableData=', this.tableData)
					})
			},
			Edit(row) {
				this.$router.push({
					path: '/PatientPage',
					query: {
						id: row.id,
						casenumber: row.casenumber,
						registerid: row.registid,
						readme: row.readme,
						present: row.present,
						history: row.hisotory,
						allergy: row.allergy,
						physique: row.physique,
						proposal: row.proposal,
						careful: row.careful,
						checkresult: row.checkresult,
						diagnosis: row.diagnosis,
						handling: row.handling,
						casestate: row.casestate
					}
				})
			},
			selectUndefinite() {
				let url = '/MedicalRecord/selectUndefinite';
				this.$axios.post(url)
					.then((resp) => {
						this.tableData = resp.data;
						console.log(this.tableData)
					})
			},
			selectDefinite() {
				let url = '/MedicalRecord/selectDefinite';
				this.$axios.post(url)
					.then((resp) => {
						this.tableData = resp.data;
						console.log(this.tableData)
					})
			},
		}
	}
</script>

<style scoped>

</style>
